<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var max = (arr, fn) => {
            var max = arr[0];
            for (let i = 1; i < arr.length; i++) {
                max = fn(max, arr[i])
            }
            return max;
        }
        var maxnum = max([0, 1, 2, 3, 1, 2, 3, 1, 8, 7], (a, b) => a > b ? a : b)
        console.log(maxnum);
    </script>
</head>

<body>

</body>

</html>